package cn.ecut.servlet;


import cn.ecut.services.GoodServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/lost/returnlost")
public class ChangeLostState extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();

        int goodid=(Integer.parseInt(request.getParameter("goodId")));

        GoodServices gservice=new GoodServices();
        boolean result = gservice.updateGoodState(goodid);
        if (result) {
            request.setAttribute("msg", "修改成功");
            request.getRequestDispatcher("/mypost.jsp").forward(request, response);
        } else {
            request.setAttribute("msg", "修改失败");
            request.getRequestDispatcher("/mypost.jsp").forward(request, response);
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        doGet(request,response);
    }

}
